/* jQuery screens switch code here */

var current_screen = 1;
var screen_id = 1;
var current_name = "tel";
var screen_name = "tel";
var active_button = "/img/dot2.gif";
var inactive_button = "/img/dot1.gif";
var total_screens = 4;
var last_screen = new Array();
last_screen['tel'] = 1;
last_screen['sms'] = 1;
last_screen['mail'] = 1;
last_screen['map'] = 1;
last_screen['web'] = 1;
last_screen['store'] = 1;
last_screen['poll'] = 1;
last_screen['templ1'] = 1;
last_screen['templ2'] = 1;
last_screen['templ3'] = 1;

	
function CheckName(screen_name) {
	if (current_name!=screen_name) {
		last_screen[current_name] = current_screen;
		current_name = screen_name;
		current_screen = last_screen[current_name];
	}
}	
	
function SwitchPrevious(screen_name) {
	
	CheckName(screen_name);
	
	if (current_screen==1) {
		next_screen = total_screens;
	} else {
		next_screen = current_screen - 1;
	}
	
	SwitchScreen(screen_name,next_screen);
	
}

function SwitchNext(screen_name) {

	CheckName(screen_name);

	if (current_screen==total_screens) {
		next_screen = 1;
	} else {
		next_screen = current_screen + 1;
	}
	
	SwitchScreen(screen_name,next_screen);
}

function SwitchScreen(screen_name,screen_id) {

	if (screen_id != current_screen) {


		// ## Switch it!

		// Switch buttons
		$("#b"+screen_name+current_screen).attr({src: inactive_button});
		$("#b"+screen_name+screen_id).attr({src: active_button});
		
		// Switch URLs 
		// $(this).attr({scr: active_button});

		// Switch screens
		$("#s"+screen_name+current_screen).hide();
		$("#s"+screen_name+screen_id).fadeIn("slow");
		
		// Switch info
		$("#i"+screen_name+current_screen).hide();
		$("#i"+screen_name+screen_id).fadeIn("slow");
		
		// Save current screen id
		current_screen = screen_id;
		current_name = screen_name;
		
	}
	
}